﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SYH.Product.BLL
{
    public class ProductInfo
    {
        private static readonly SYH.Product.DAL.ProductInfo dal = new DAL.ProductInfo();
        #region 产品标题是否存在
        /// <summary>
        /// 产品标题是否存在
        /// </summary>
        /// <returns></returns>
        public static bool TitleExists(int userId, string title)
        {

            return dal.TitleExists(userId, title);

        }
        #endregion

        #region 增加产品
        /// <summary>
        /// 增加产品
        /// </summary>
        /// <param name="model"></param>
        /// <param name="oftenText">常用分类名</param>
        /// <param name="oftenValue">常用分类值</param>
        /// <param name="imgList">产品图片</param>
        /// <param name="imgList">产品图片ID</param>
        /// <returns></returns>
        public static int Add(Model.ProductInfo model)//, string oftenText, string oftenValue, string imgNameList, string imgIdList
        {
            return dal.Add(model);
        }
        #endregion

        #region 更新产品
        /// <summary>
        /// 更新产品
        /// </summary>
        /// <param name="model"></param>
        /// <param name="oftenText">常用分类名</param>
        /// <param name="oftenValue">常用分类值</param>
        /// <param name="imgList">产品图片</param>
        /// <param name="imgList">产品图片ID</param>
        /// <returns></returns>
        public static int Update(Model.ProductInfo model)//string oftenText, string oftenValue, string imgNameList, string imgIdList
        {
            return dal.Update(model);

        }
        #endregion

        #region 根据id获取产品供应信息标题
        /// <summary>
        /// 根据id获取产品供应信息标题 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static string GetSupplyTitleById(int id)
        {
            return dal.GetSupplyTitleById(id);
        }
        #endregion

        #region 根据用户编号得到产品数量
        /// <summary>
        /// 根据用户编号得到产品数量
        /// </summary>
        /// <param name="Uid">用户Id</param>
        /// <returns></returns>
        public static int GetCountProduct(int Uid)
        {
            return dal.GetCountProduct(Uid);
        }
        #endregion

        #region 根据Id获取model
        /// <summary>
        /// 得到一个产品对象实体 根据主键
        /// </summary>		
        public static Model.ProductInfo GetModel(int Id)
        {

            return dal.GetModel(Id);
        }
        #endregion

        #region 删除产品
        /// <summary>
        /// 删除产品
        /// </summary>
        public static int Delete(int UserId, string idList)
        {

            return dal.Delete(UserId, idList);


        }
        #endregion


        #region 更新一个字段
        /// <summary>
        /// 更新一个字段
        /// </summary>
        /// <param name="name">字段名</param>
        /// <param name="value">值</param>
        /// <param name="strWhere">条件</param>
        /// <param name="flag">字符串表示：true为字符串；false为整型、bool、日期等</param>
        /// <returns></returns>
        public static bool UpdateOneField(string name, string value, string strWhere, bool flag)
        {


            return dal.UpdateOneField(name, value, strWhere, flag);
        }
        #endregion

        #region 根据用户和状态获得采购商品数目
        public static int GetCountByStatusUserId(int userId, int status)
        {

            return dal.GetCountByStatusUserId(userId, status);
        }
        #endregion

        #region 根据用户ID获取最新发布产品编号
        public static int GetProductIdByUserId(int userId)
        {
            return dal.GetProductIdByUserId(userId);
        }
        #endregion
    }
}
